#!/usr/bin/env /usr/local/python3
# -*- coding: utf-8 -*-

import cv2

"""
读取视频流
"""

__author__ = "hubert"


# 江苏移动  http://223.110.243.225:80/3/16/20211017/283970963/283970963.ts?OTTUserToken=&UserName=13813077105&MAC=c0:13:2b:78:0f:5b&accountinfo=FyXxANG94DUPayESlQuvXCJblRL8rMpGrS85ef1Azejgd9YcV2Fb9aG%2BexJ2L8k%2FhhSCm2B%2B20nuuO%2BU25p%2F6yhmh1ULarFpwOD%2FDrALv7mSnCVEpjbxK7A5rqANlgdSb%2BQbgaDAxf3trV0ldHKBPQ%3D%3D%3A20211020101033%2C13813077105%2C39.170.43.26%2C20211020101033%2Cp_32945482%2C571C96322EFD74CC4E0C6730087862B3%2C%2C1%2C0%2C-1%2C%2C1%2C%2C-1%2C-3%2C1%2CEND&GuardEncType=2&servicetype=0&icpid=88888888&from=1&hms_devid=6447
# 10M 21s http://file.seeingtv.com/targetPath/20210909/630b007838270c9a2c4d8443d203f910.ts
# 8G http://file.seeingtv.com/targetPath/20211022/69cfbf4b7f46f6bfe3db9490c7136e4f.ts
# https://valipl.cp31.ott.cibntv.net/657221246913B7195C1FC6EB8/0300030000622F0C958BB7800000002296B028-46CF-41BF-84BD-662589E39385.m3u8?ccode=0502&duration=629&expire=18000&psid=c411a862568ee77ad8462aa826d1164041346&ups_client_netip=6f0052e9&ups_ts=1650521855&ups_userid=&utid=MpcnGkfhE1oCATywluVXPvdk&vid=XNTIwMTE2MTQ5Ng%3D%3D&vkey=B39b3d753865ca4c2d168fab70f9ce7c7&s=eacdafb09f604595bcb6&eo=1&t=d4a2ad25298c25c&cug=1&rid=200000009BFEC45B43597301788899B3260BE0C802000000&type=3gphdv3&bc=2&dre=u37&si=73&dst=1&sm=1&operate_type=1
if __name__ == '__main__':
    # "/Users/hubert/Downloads/视频测试/6F5C899975164C19B602A8A992FA3169.ts"
    video_path = "https://valipl.cp31.ott.cibntv.net/657221246913B7195C1FC6EB8/0300030000622F0C958BB7800000002296B028-46CF-41BF-84BD-662589E39385.m3u8?ccode=0502&duration=629&expire=18000&psid=c411a862568ee77ad8462aa826d1164041346&ups_client_netip=6f0052e9&ups_ts=1650521855&ups_userid=&utid=MpcnGkfhE1oCATywluVXPvdk&vid=XNTIwMTE2MTQ5Ng%3D%3D&vkey=B39b3d753865ca4c2d168fab70f9ce7c7&s=eacdafb09f604595bcb6&eo=1&t=d4a2ad25298c25c&cug=1&rid=200000009BFEC45B43597301788899B3260BE0C802000000&type=3gphdv3&bc=2&dre=u37&si=73&dst=1&sm=1&operate_type=1"
    # cv2.VideoCapture(0) # 打开本地摄像头

    cap = cv2.VideoCapture("/Users/hubert/Downloads/视频测试/6F5C899975164C19B602A8A992FA3169.ts")  # rtsp://admin:admin@192.168.2.64:554//Streaming/Channels/1
    while cap.isOpened():
        # retval 布尔值
        retval, image = cap.read()
        if not retval:  # 读完视频后falg返回False
            break
        print(cap.get(0))  # cap.get(0) 视频文件的当前位置（播放）以毫秒为单位
        # """
        if retval:
            # 可调整视频窗大小
            # cv2.namedWindow("Video_Frame", cv2.WINDOW_NORMAL)
            # 设置视频窗默认大小
            # cv2.resizeWindow("Video_Frame", 640, 480);
            frame = cv2.resize(image, None, fx=0.5, fy=0.5)
            # 显示视频窗
            cv2.imshow("Video_Frame", frame)
        # """
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    cv2.destroyAllWindows()
    cap.release()





